<template>
  <section>
    <el-row>
      <el-col :span="24">
        <el-form :inline="true">
          <el-form-item>
            <el-button type="primary" @click="handleRefresh()">强制刷新节点</el-button>
          </el-form-item>
        </el-form>
        <el-table :data="tableData" border size="small">
          <el-table-column prop="node" label="系统节点">
            <template #default="scope">
              <div v-html="scope.row.node"></div>
            </template>
          </el-table-column>
          <el-table-column prop="title" label="节点名称" align="center"></el-table-column>
          <el-table-column prop="update_at" label="更新时间" align="center"></el-table-column>
          <el-table-column prop="create_at" label="添加时间" align="center"></el-table-column>
        </el-table>
      </el-col>
    </el-row>
  </section>
</template>
<script setup>
  import { ref } from "vue";
  import { ElMessage,ElMessageBox } from 'element-plus'
  import func from '@/common/func'
  const tableData = ref([])

  loadData();
  function handleRefresh() {
    ElMessageBox.confirm('确认刷新吗？', '提示').then(() => {
      func.request('/system/refreshNode', {}).then(res => {
        if (res.code === 1) {
          ElMessage({message: res.msg,type: 'success'})
          loadData()
        }
      });
    }).catch(()=>{})
  }
  function loadData () {
    func.request('/system/nodeList', {}).then(res => {
      if (res.code === 1) {
        tableData.value = res.data.list;
      }
    });
  }

</script>
<style lang="scss" scoped>

</style>
